package com.clayecloud.module_report_repair.entity;

import android.widget.ImageView;
import android.widget.TextView;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
import androidx.databinding.BindingAdapter;

import com.clayecloud.module_report_repair.R;

import java.util.Date;

public class ReportRepair extends BaseObservable {

    /**
     * 报事报修id
     */
    private Long rrId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 报事报修类型
     */
    private Integer rrType;

    /**
     * 报事报修富文本内容存储
     */
    private String rrContent;

    /**
     * 报修地址
     */
    private String rrAddress;

    /**
     * 联系人姓名
     */
    private String rrUsername;

    /**
     * 联系电话
     */
    private String rrPhone;

    /**
     * 报事报修状态
     */
    private Integer rrState;

    /**
     * 创建时间
     */
    private String creatTime;

    /**
     * 更新时间
     */
    private String updateTime;

    /**
     * 用户昵称
     */
    private String userName;


    @Bindable
    public Long getRrId() {
        return rrId;
    }

    public void setRrId(Long rrId) {
        this.rrId = rrId;
    }

    @Bindable
    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    @Bindable
    public Integer getRrType() {
        return rrType;
    }

    public void setRrType(Integer rrType) {
        this.rrType = rrType;
    }

    @Bindable
    public String getRrContent() {
        return rrContent;
    }

    public void setRrContent(String rrContent) {
        this.rrContent = rrContent;
    }

    @Bindable
    public String getRrAddress() {
        return rrAddress;
    }

    public void setRrAddress(String rrAddress) {
        this.rrAddress = rrAddress;
    }

    @Bindable
    public String getRrUsername() {
        return rrUsername;
    }

    public void setRrUsername(String rrUsername) {
        this.rrUsername = rrUsername;
    }

    @Bindable
    public String getRrPhone() {
        return rrPhone;
    }

    public void setRrPhone(String rrPhone) {
        this.rrPhone = rrPhone;
    }

    @Bindable
    public Integer getRrState() {
        return rrState;
    }

    public void setRrState(Integer rrState) {
        this.rrState = rrState;
    }

    @Bindable
    public String getCreatTime() {
        return creatTime;
    }

    public void setCreatTime(String creatTime) {
        this.creatTime = creatTime;
    }

    @Bindable
    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    @Bindable
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @BindingAdapter("typeHandle")
    public static void getCoverPhoto(ImageView view, String type) {
        if("0".equals(type)){
            view.setBackgroundResource(R.drawable.report);
        }else{
            view.setBackgroundResource(R.drawable.repair);
        }
    }

    @BindingAdapter("stateHandle")
    public static void stateHandle(TextView view, String state) {
        if("0".equals(state)){
            view.setText("已创建");
        }else if("1".equals(state)){
            view.setText("正在审核");
        }else if("2".equals(state)){
            view.setText("正在处理");
        }else if("3".equals(state)){
            view.setText("已完成");
        }else{
            view.setText("未知");
        }

    }
}
